<dl class="memberwlist">
	<?php foreach ($worklist as $key => $work):?>
    <div class="del"><a onclick="del('<?=$work['id']?>')">删除作品</a></div>
	<dt class="right">
		<div class="info">
			<h1 class="editable" data-id="<?=$work['id']?>" data-field="title" data-info="<?=$work['title']?>" ><b>主题：</b><span class="editcont"><?=utf8_substr($work['title'],10)?></span></h1>
			<div class="pubtime">发布：<?=$work['puttime']?></div>
			<div class="story">
				<div class="editthis"><a class="contentedit" >编辑</a></div>
                <div class="editthis2" style="display:none"><a class="cancelcontent">取消</a><a  class="savecontent" >保存</a></div>
				<h2>故事：</h2>
				<div class="content"  style="display:none">
                	 <?=$work['content']?>
				</div>
                <div class="subcontent">
                    <?=utf8_substr($work['content'],96)?>
				</div>
                <div class="editcont" style="display:none">
                	<textarea name="content"  id="workcontent"> <?=$work['content']?></textarea>
                    <input name="workid" value="<?=$work['id']?>"  type="hidden"  id="workid"/>
                </div>
			</div>
            <div class="showmore" style="display:<?=is_substr($work['content'],96)?'block':'none'?>">展开>></div>
		</div>
		<div class="memberico">
			<div class="icos ani" data-mid="<?=$member->mid?>" data-id="<?=$work['id']?>">
				<div class="iline"><a href="javascript:" class="ico icosupport"><span><span class="right"><?php echo $work['goodnum'];?></span>特赞</span></a></div>
				<div class="iline"><a href="javascript:" class="ico icolike"><span><span class="right"><?php echo $work['watchnum'];?></span>关注</span></a></div>
				<div class="iline"><a href="javascript:" class="ico icocomment"><span><span class="right"><?php echo $work['commnum'];?></span>评论</span></a></div>
				<div class="iline"><a href="javascript:" class="ico icoview"><span><span class="right"><?php echo $work['viewnum'];?></span>浏览</span></a></div>
				<div class="iline last"><span class="ico icoshare" data-url="<?=site_url('space/work/'.$member->mid.'/'.$work['id']);?>" data-title="<?=$work['title'];?>" data-picture="<?=site_url($work['image']);?>" data-summary="<?=utf8_substr($work['summary'],50)?>"><span><?php echo $work['shares'];?></span></span></div>
			</div>
		</div>
	</dt>
	<dd class="left images">
		<div class="view"><a href="<?=$work['image']?>" class="fancybox" data-fancybox-group="work<?=$work['id']?>" ><img src="<?=$work['image']?>" onload="OverImage(this,400,300)"  /></a></div>
		<div class="list">
			<ul>
				<?php if(isset($work['images'])):foreach ($work['images'] as $key => $value):if($value['image']==$work['image'])continue;?>
					<li><a href="<?=$value['image']?>" class="fancybox" data-fancybox-group="work<?=$work['id']?>"><img src="<?=$value['image']?>" onload="OverImage(this,90,73)" alt="<?=$value['desc']?>"></a></li>
				<?php endforeach;endif;?>
			</ul>
		</div>
	</dd>
	<dd class="left comment">
	<div class="commentlist">
    	<ul>
			<?php if(isset($work['comments'])):foreach ($work['comments'] as $key => $msg):?>
                <li>
                <a class="avatar" href="<?=site_url('space/'.$msg['mid'])?>"><img src="<?=$msg['avatar']?>" alt="<?=empty($msg['mnick'])?$msg['mname']:$msg['mnick']?>"/></a>
                <a class="name" href="<?=site_url('space/'.$msg['mid'])?>"><?=empty($msg['mnick'])?$msg['mname']:$msg['mnick']?></a>
                <div class="msgcont"><?=$msg['content']?></div>
                <div class="info"><?=date('Y.m.d H:i',$msg['puttime'])?>&nbsp;&nbsp;&nbsp;<span class="recomment" style="display:<?=count($msg['remsglist'])>0?'none':'block'?>">回复</span></div>
                <div class="commentform"  style="display:none">
                <div class="clearfix"> </div>
                    <form name="memberComment" class="commentform" method="post" action="<?=site_url('space/workcomm/'.$msg['mid'].'/'.$msg['wid'])?>" >
                    <textarea name="content" placeholder="回复什么吧" id="replay"></textarea>
                    <input type="hidden" name="reid" value="<?=$msg['id']?>" />
                    <input type="submit" class="subbtn" value="回复点评" />
                     </form>
                </div>
                <?php if (count($msg['remsglist'])>0){?>
                    <div class="clearfix commre"><!--回复-->
                        <a class="name2" href="<?=site_url('space/'.$msg['remsglist']['mid'])?>"><?=empty($msg['remsglist']['mnick'])?$msg['remsglist']['mname']:$msg['remsglist']['mnick']?>：</a><span><?=$msg['remsglist']['content']?></span>
                    </div>
                <?php }?>
                </li>
            <?php endforeach;endif;?>
        </ul>
	</div>
	</dd>
	<dd class="clear line2"></dd>
	<?php endforeach;?>
</dl>
<script type="text/javascript" >
$('.editable').editAble({action:'<?=site_url('member/savework')?>'});
$(document.memberComment).validation();

function del(id){
    var id=id;
    if(confirm('您确定删除此故事？')){
    
         $.ajax({
            url:'/member/deletework/'+id,
            type:'POST',
            dataType:'json',
            success:function(j){
                tip('删除成功！',0,2);
                location.reload();
            }
        })
		
       
    }
}


$(".contentedit").each(function(){   
		$(this).bind("click", function() {
			$(this).parent('.editthis').hide();	
			$(this).parent('.editthis').next('.editthis2').show();
			$(this).parent('.editthis').parent('.story').children('.editcont').show();	
			$(this).parent('.editthis').parent('.story').children('.content').hide();
			$(this).parent('.editthis').parent('.story').children('.subcontent').hide();
			$(this).parent('.editthis').parent('.story').next('.showmore').hide();

	});
 })


$(".cancelcontent").each(function(){   
		$(this).bind("click", function() {
			$(this).parent('.editthis2').hide();	
			$(this).parent('.editthis2').prev('.editthis').show();	
			$(this).parent('.editthis2').parent('.story').children('.editcont').hide();	
			$(this).parent('.editthis2').parent('.story').next('.showmore').show();
			var aa=$(this).parent('.editthis2').parent('.story').next('.showmore').text();
			if(aa=='展开>>'){
				$(this).parent('.editthis2').parent('.story').children('.subcontent').show();
				$(this).parent('.editthis2').parent('.story').children('.content').hide();
			}else{
				$(this).parent('.editthis2').parent('.story').children('.subcontent').hide();
				$(this).parent('.editthis2').parent('.story').children('.content').show();
			}
		
	});
 })


$(".savecontent").each(function(){   
		$(this).bind("click", function() {

			var content=$(this).parent('.editthis2').parent('.story').children('.editcont').children("#workcontent").val();
			var id=$(this).parent('.editthis2').parent('.story').children('.editcont').children("#workid").val();
			 $.post("<?=site_url('member/savework')?>", {id:id,content:content,act:'saveinfo'}, function(j){
   				if(j.errorcode=='0'){
					tip('更新成功！',0,2);
               	     location.reload();
				}
			}
			,"json"); 
	});
 })
   
//字数
window.onload = function() 
{ 
	document.getElementById('workcontent').onkeydown = function() 
	{    
		if(this.value.length >= 600) {	
			 var num=this.value.substr(0,600);
			 alert('你的故事已经超过600字！');
		}
		 
	} 
} 
</script>